export default {
  namespaced: true,
  actions: {
    addOdd(context, value) {
      if (context.state.num % 2) {
        context.commit('saveAdd', value)
      }
    },
    addWait(context, value) {
      setTimeout(() => {
        context.commit('saveAdd', value)
      }, 500)
    }
  },
  mutations: {
    saveAdd(state, value) {
      console.log('saveAdd', state, value)
      state.num += value;
    },
    savePlus(state, value) {
      state.num -= value;
    },
  },
  state: {
    userName: 'Zoe',
    subject: '前端',
    num: 0,
  },
  getters: {
    bigNum(state) {
      return state.num * 10
    }
  }
}
